﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Host.CTR;
using System.Threading.Tasks;
using Host.Model;
namespace Host
{
    class Program
    {
        static void Main(string[] args)
        {
            locationCtr lctr = new locationCtr();
            Console.WriteLine("1 for se byer - 2 for vælge på ID - 3 for at oprette by - 4 for at opdatere by");
            string caseSwitch = Console.ReadLine();
            switch (caseSwitch)
            {
                case "1":
                    foreach (var location in lctr.getLocation())
                     {
                         Console.WriteLine(location.ID + "  " + location.City.ToString());
                     }
                    break;
                case "2":
                    Console.WriteLine("SKriv et id");
                    string ID = Console.ReadLine();

                    location l = lctr.getCityByID(ID);
                    Console.WriteLine(l.City.ToString());
                    break;

                case "3":
                    Console.WriteLine("Skriv et navn til byen");
                    string cityName = Console.ReadLine();
                    lctr.insertLocation(cityName);
                    Console.WriteLine("Du har oprettet byen: " + cityName);


                    break;

                case "4":
                    Console.WriteLine("Skriv ID der skal opdateres");
                    string cityID = Console.ReadLine();
                    location cityL = lctr.getCityByID(cityID);
                    Console.WriteLine("Du har valgt at opdatere: " + cityL.City.ToString());
                    Console.WriteLine("Skriv det nye bynavn");
                    string newCityName = Console.ReadLine();
                    lctr.updateLocation(newCityName, Convert.ToInt32(cityID));
                    Console.WriteLine("Du har opdateret: " + cityL.ID + " til: " + newCityName);
                    break;
                default:
                    Console.WriteLine("Default case");
                    break;

            }

            Console.Read();
            
            
            
            

            

            
            


            

            

        }


    }
}
